home *** CD-ROM | disk | FTP | other *** search
/ 9-Digit Zip Code Directory / 9-Digit Zip Code Directory (American Business Information) (ABIZIP-12).ISO / z4src.zip / BS.C < prev    next >
C/C++ Source or Header  |  1993-09-02  |  5KB  |  231 lines

  1. //----------------------------------------------------------------------------
  2. //                            MODULE DESCRIPTION
  3. //
  4. //  Module:    base.c
  5. //   Title:    Base library
  6. //  Notice:    John M. Weeder
  7. //                 Copyright (c) 1993. All rights reserved.
  8. //             This module contains proprietary information and should be 
  9. //                treated as confidential.
  10. //
  11. //----------------------------------------------------------------------------
  12. //                           MAINTENANCE HISTORY
  13. //
  14. // $Workfile$
  15. // $Revision$
  16. //   $Author$
  17. //     $Date$
  18. //      $Log$    
  19. //
  20. //----------------------------------------------------------------------------
  21. //                             MODULE NARRATIVE
  22. //
  23. //
  24. //    This module contains code to test the base library.
  25. //
  26. //    The code in this module should be written entirely in C. 
  27. //    Do not use any C++ constructs.
  28. //
  29. //    This module is portable to:
  30. //        DOS 3.X+
  31. //        MS Windows 3.X+
  32. //        OS/2 2.X+
  33. //        OS/2 2.0 PM
  34. //        SCO UNIX.
  35. //
  36. //    The following compilers are supported:
  37. //        MSC 6.0A
  38. //        MSC/C++ 7.0
  39. //        Borland C++ 3.1 for DOS
  40. //        Borland C++ 1.0 for OS/2 2.X
  41. //        SCO UNIX cc
  42. //
  43. //----------------------------------------------------------------------------
  44. #include <bs.h>
  45.  
  46.  
  47. //----------------------------------------------------------------------------
  48. //    Stack size
  49. //----------------------------------------------------------------------------
  50. #if COMPILER_BORLAND && (OS_DOS || OS_WINDOWS)
  51. unsigned _stklen = 0x4000;
  52. #endif
  53.  
  54.  
  55. typedef BOOL (FN *PFNTEST)(SHORT);
  56.  
  57.  
  58. //----------------------------------------------------------------------------
  59. //   Description:    main() - Program entry point
  60. //    Parameters:    Standard C parameters
  61. //       Returns:    DOS return code.
  62. //----------------------------------------------------------------------------
  63. int main(int argc, char **argv)
  64. {
  65. static PSZ apszTest[] =
  66.     {
  67.     "ASSERT",
  68.     "BCD",
  69.     "BOOT",
  70.     "COMMANDLINE",
  71.     "COPY",
  72.     "CPU",
  73.     "CRC",
  74.     "CRITERR",
  75.     "DEBUG",
  76.     "DISPLAY",
  77.     "DRIVE",
  78.     "EBCDIC",
  79.     "ENV",
  80.     "ERROR",
  81.     "FILE",
  82.     "FINFO",
  83.     "FNAME",
  84.     "GARBLE",
  85.     "HALT",
  86.     "HEAP",
  87.     "IO",
  88.     "KBD",
  89.     "LEV",
  90.     "LOG",
  91.     "MEM",
  92.     "META",
  93.     "MSCDEX",
  94.     "NOVELL",
  95.     "PARENT",
  96.     "PASSWORD",
  97.     "PID",
  98.     "PIPE",
  99.     "PRINT",
  100.     "PRINTSCREEN",
  101.     "PROGSIZE",
  102.     "QUERY",
  103.     "RANDOM",
  104.     "REV",
  105.     "SERIAL",
  106.     "SLEEP",
  107.     "SOUND",
  108.     "STRING",
  109.     "TEXTIN",
  110.     "TEXTOUT",
  111.     "THREAD",
  112.     "TOKEN",
  113.     "UMB",
  114.     "VERSION",
  115.     "VOLLBL",
  116.     "WRAP",
  117.     NULL
  118.     };
  119. static PFNTEST apfntest[] =
  120.     {
  121.     AssertTest,
  122.     BcdTest,
  123.     BootTest,
  124.     CommandLineTest,
  125.     CopyTest,
  126.     CpuTest,
  127.     CrcTest,
  128.     CritErrTest,
  129.     DebugTest,
  130.     DisplayTest,
  131.     DriveTest,
  132.     EbcdicTest,
  133.     EnvTest,
  134.     ErrorTest,
  135.     FileTest,
  136.     FinfoTest,
  137.     FnameTest,
  138.     GarbleTest,
  139.     HaltTest,
  140.     HeapTest,
  141.     IOTest,
  142.     KbdTest,
  143.     LevTest,
  144.     LogTest,
  145.     MemTest,
  146.     MetaTest,
  147.     MscdexTest,
  148.     NovellTest,
  149.     ParentTest,
  150.     PasswordTest,
  151.     PidTest,
  152.     PipeTest,
  153.     PrintTest,
  154.     PrintScreenTest,
  155.     ProgSizeTest,
  156.     QueryTest,
  157.     RandomTest,
  158.     RevisionTest,
  159.     SerialTest,
  160.     SleepTest,
  161.     SoundTest,
  162.     StringTest,
  163.     TextInTest,
  164.     TextOutTest,
  165.     ThreadTest,
  166.     FileTokenTest,
  167.     UmbTest,
  168.     VersionTest,
  169.     VolLblTest,
  170.     WrapTest,
  171.     };
  172. static BOOL fHelp = FALSE;
  173. static LONG lTest = 0;
  174. static CHAR szTest[80];
  175. static BS_CMDOPT acmdopt[] =
  176.     {
  177.     { "TEST",        (PVOID)&lTest, CMDOPT_NUMERIC,                            "Test number\nLine 2"},
  178.     { "test_name", (PVOID)szTest, _CMDOPT_FILESPEC|CMDOPT_REQUIRED|80, "Name of test"},
  179.     BS_CMDOPT_NULL
  180.     };
  181. static BS_CFG cfg = CFG_DFT;
  182.  
  183.     BOOL fFound = FALSE;
  184.     BOOL fResult;
  185.     SIZET i;
  186.  
  187.     BaseLibraryInitialize(argc, argv, &cfg);
  188.     BaseTitle("$Revision:   93.1  $", __DATE__, __TIME__, "Base Library Test Program");
  189.     if (BaseTitleHelp(acmdopt, "Base library test program description", 0))
  190.         {
  191.         for (i = 0; apszTest[i]; ++i)
  192.             {
  193.             if (stricmp(szTest, apszTest[i]) == 0)
  194.                 {
  195.               fFound = TRUE;
  196.                 if (lTest)
  197.                     printf("\n%s Test #%ld:\n\n", apszTest[i], lTest);
  198.                 else
  199.                     printf("\n%s Test.\n\n", apszTest[i]);
  200.  
  201.                 fResult = (*apfntest[i])((SHORT)lTest);
  202.                 break;
  203.                 }
  204.             }
  205.         if (fFound)
  206.             {
  207.             if (!fResult)
  208.                 {
  209.                 printf("\nTest failed!\n");
  210.                 return 2;
  211.                 }
  212.             else
  213.                 {
  214.                 printf("\nTest succeeded!\n");
  215.                 }
  216.             }
  217.         }
  218.     if (!fFound || fHelp)
  219.         {
  220.         printf("Select one of the following options:\n");
  221.         for (i = 0; apszTest[i]; ++i)
  222.             printf("    %s\n", apszTest[i]);
  223.  
  224.         return 1;
  225.         }
  226.     return 0;
  227. }
  228. //----------------------------------------------------------------------------
  229. //------------------------------- End of File --------------------------------
  230. //----------------------------------------------------------------------------
  231.